/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.mec.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Juanky
 */
@Entity
@Table(name = "profesor_curso")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ProfesorCurso.findAll", query = "SELECT p FROM ProfesorCurso p"),
    @NamedQuery(name = "ProfesorCurso.findById", query = "SELECT p FROM ProfesorCurso p WHERE p.id = :id"),
    @NamedQuery(name = "ProfesorCurso.findByCurso", query = "SELECT p FROM ProfesorCurso p WHERE p.curso = :curso")})
public class ProfesorCurso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "curso")
    private int curso;
    @Lob
    @Size(max = 65535)
    @Column(name = "extra")
    private String extra;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "profesorCursoId")
    private List<Curso> cursoList;
    @JoinColumn(name = "profesor_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Usuario profesorId;

    public ProfesorCurso() {
    }

    public ProfesorCurso(Integer id) {
        this.id = id;
    }

    public ProfesorCurso(Integer id, int curso) {
        this.id = id;
        this.curso = curso;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getCurso() {
        return curso;
    }

    public void setCurso(int curso) {
        this.curso = curso;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    @XmlTransient
    public List<Curso> getCursoList() {
        return cursoList;
    }

    public void setCursoList(List<Curso> cursoList) {
        this.cursoList = cursoList;
    }

    public Usuario getProfesorId() {
        return profesorId;
    }

    public void setProfesorId(Usuario profesorId) {
        this.profesorId = profesorId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProfesorCurso)) {
            return false;
        }
        ProfesorCurso other = (ProfesorCurso) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mx.itsc.mec.modelo.ProfesorCurso[ id=" + id + " ]";
    }
    
}
